package StudyCode.UI;

import javax.swing.*;
import java.awt.*;

/**
 * @author lixiaoyao
 * @date 2018/11/12 0012、下午 12:37
 * @description setLocationByPlatform测试类
 */
public class SizedFrameTest {
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				JFrame frame = new SizedFrame();
				frame.setTitle("SizedFrame");
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setVisible(true);
			}
		});
	}

}

class SizedFrame extends JFrame {
	public SizedFrame() {
		// get screen dimensions

		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension dimension = kit.getScreenSize();

		//set frame width,hiehgt and let platform pick screen location
		setSize((int) dimension.getWidth() / 2, (int) dimension.getHeight() / 2);
		setLocationByPlatform(true);
	}


}
